<template>
    <a-card :bordered="false">
    <!-- 左侧面板 -->
    <div class="table-page-search-wrapper">
        <!-- form表单 -->
      <a-form layout="inline">
        <a-row :gutter="12">
          <a-col :md="7" :sm="8">
            <a-form-item label="商品类型名称" :labelCol="{span: 6}" :wrapperCol="{span: 14, offset: 1}">
              <a-input placeholder="请输入商品类型名称" v-model="queryParam.typeName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="7" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>

      <div class="table-operator" style="border-top: 5px">
        <a-button @click="handleAdd" type="primary" icon="plus">添加</a-button>

      </div>

      <a-table
        ref="table"
        rowKey="id"
        size="middle"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">
            <a-icon type="edit"/>
            编辑
          </a>
          <a-divider type="vertical"/>
           <a @click="toRelationship(record.typeId)">
            <a-icon type="setting"/>
            配置滤芯
          </a>
          <a-divider type="vertical"/>
          <a-popconfirm title="确定删除吗?" @confirm="() =>handleDelete(record.typeId)">
            <a>删除</a>
          </a-popconfirm>
        </span>
      </a-table>

    </div>
  <!-- 把新增修改页面变为查询页面的内部的div，默认是隐藏状态，点击新增或者修改时变为显示状态 -->
  <!--@ok如果父页面监听到子页面返回Ok,调用modalFormOk方法-->
  <commodity-type-model ref="modalForm" @ok="modalFormOk"></commodity-type-model>
  <relationship-list ref="relationship"></relationship-list>
  </a-card>
</template>
<script>
//导包
  import { filterObj } from '@/utils/util';
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import CommodityTypeModel  from './model/CommodityTypeModel'
  import RelationshipList from './RelationshipList'
    //对象内容
  export default {
    //对象名称
    name: "CommodityTypeList",
    //申明导入的对象
    mixins:[JeecgListMixin],
    //声明引用的页面
    components:{CommodityTypeModel,RelationshipList},
    //对象中的变量
    data() {
      return {
        description: '这是数据字典页面',
        visible: false,
        // 查询条件
        queryParam: {
          typeName: "",
        },
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 120,
            align: "center",
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title: '类型名称',
            align: "left",
            dataIndex: 'typeName',
          },
          {
            title: '滤芯规格',
            align: "left",
            dataIndex: 'specification',
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: "center",
            scopedSlots: {customRender: 'action'},
          }
        ],
        labelCol: {
          xs: {span: 8},
          sm: {span: 5},
        },
        wrapperCol: {
          xs: {span: 16},
          sm: {span: 19},
        },
        url: {
          list:"/commodity/commodityType/list",
          delete:"/commodity/commodityType/del",
          imgerver:window._CONFIG['domianURL']+"/sys/common/view"
        },
      }
    },
    methods: {
        //对象中的方法
      getAvatarView: function (avatar) {
        console.log(this.url.imgerver + "/" + avatar);
        return this.url.imgerver + "/" + avatar;
      },
      toRelationship(typeeId){
           this.$refs.relationship.add(typeeId);
      }
    },
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>